from selenium import  webdriver
import time
from selenium.webdriver.common.by import By


driver = webdriver.Chrome(r'D:\bianchengerbianchenger\driver\chromedriver.exe')
driver.get('https://mail.qq.com/')

driver.maximize_window()
time.sleep(2)
#-------------------登录---------------------------
f = driver.find_element(By.ID,'login_frame')
driver.switch_to.frame(f)       #切入框架
driver.find_element(By.CSS_SELECTOR,'span[id^="nick_2274184615"]').click()
driver.switch_to.default_content()      #切出框架
time.sleep(2)
#点击写信
driver.find_element(By.CSS_SELECTOR,'a[id^="composebtn"]').click()
time.sleep(2)
#-----------------开始写邮件收件人标题----------------------

f1 = driver.find_element(By.NAME,'mainFrame')
driver.switch_to.frame(f1)       #切入框架

driver.find_element(By.CSS_SELECTOR,'[aria-label="收件人"]').send_keys('2674184615@qq.com')
driver.find_element(By.CSS_SELECTOR,'[id="subject"]').send_keys('测试')

driver.find_element(By.CSS_SELECTOR,'[name="sendbtn"]').click()
#driver.switch_to.default_content()      #切出框架

#---------------------写邮件正文-----------------------
# f2 = driver.find_element(By.NAME,'_1663676882358017624795192935583')
# driver.switch_to.frame(f2)       #切入框架
# driver.find_element(By.CSS_SELECTOR,'[aria-label="正文"]').send_keys('无')
# driver.switch_to.default_content()      #切出框架
